import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Framework.*;


public class dlg_basicDialogTest extends dlg_Ancestor implements ActionListener{
	JLabel myText = new JLabel("Welcome to Test Dialogue! It counts the yes or no clicks!");
	
	btn_Ancestor btn_Close 	= new btn_Ancestor("Close");
	btn_Ancestor btn_Yes 		= new btn_Ancestor("Yes");
	btn_Ancestor btn_No 		= new btn_Ancestor("No");
	
	int YesCount = 0;
	protected void reset(){
		// This is called on deactivate. You *MUST* reset all variables to initial state unless you re-instantiate
		// later. I prefer memory consumption over cpu time anyday ;).
		YesCount = 0;
		
	}
	
	public dlg_basicDialogTest(){
		// Caller parameter is to call back the calling window, in the form of an event.
		
		super (); // Always call super at the beginning of constructor
		
		myText.setBounds(50,50,300,100);
		btn_Close.setBounds(50,300,50,50);
		btn_Yes.setBounds(50,360,50,50);
		btn_No.setBounds(50,420,50,50);
		
		this.add(myText);
		this.add(btn_Close);
		this.add(btn_Yes);
		this.add(btn_No);
		
		btn_Yes.addActionListener(this);
		btn_No.addActionListener(this);
		btn_Close.addActionListener(this);
	}
	
	public void actionPerformed(ActionEvent e) {
		String METHOD = "actionPerformed()";
		btn_Ancestor callingObject = (btn_Ancestor) e.getSource();
		
		if (callingObject.equals(btn_Close)) {
			this.deactivate();
		} else if (callingObject.equals(btn_No)){
			YesCount += -1;
			System.out.println("Removing 1");
		} else if (callingObject.equals(btn_Yes)){
			YesCount += 1;
			System.out.println("Adding 1");
		}
		 
	}
	
}
